package org.dylan.common.paging;

import org.dylan.common.model.QueryRequest;

/**
 * 
 * @author dylan
 * 
 */
public class PageRequest extends QueryRequest {
	public static final int UNLIMIT = -1;
	private int start = 0;
	private int limit = 20;

	public PageRequest() {
	}

	public PageRequest(int start, int limit) {
		start(start).limit(limit);
	}

	public PageRequest start(int start) {
		if (start < 0) {
			start = 0;
		}
		this.start = start;
		return this;
	}

	public PageRequest limit(int limit) {
		if (limit < 0) {
			limit = UNLIMIT;
		}
		this.limit = limit;
		return this;
	}
	public boolean unLimit(){
		return this.limit == UNLIMIT;
	}

	public int start() {
		return start;
	}

	public int limit() {
		return limit;
	}

}